<form class="form-horizontal m-t" id="editForm" novalidate="novalidate" >
<div class="col-sm-6">
	<div class="form-group ">
       <label class="col-sm-3 control-label">登录名：</label>
       <div class="col-sm-8">
       		<input  name="id" class="form-control" type="hidden" value="${user.id}" >
           <input id="loginName" name="loginName" class="form-control" type="text" value="${user.loginName}"  >
       </div>
   </div>
   <div class="form-group ">
       <label class="col-sm-3 control-label">显示名称：</label>
       <div class="col-sm-8">
           <input id="showName" name="showName" class="form-control" type="text" value="${user.showName}">
       </div>
   </div>
   <div class="form-group">
               <label class="col-sm-3 control-label">密码：</label>
               <div class="col-sm-8">
                   <input id="loginPwd" name="loginPwd" class="form-control" type="password" value="${user.loginPwd}">
               </div>
      </div>
  <div class="form-group">
               <label class="col-sm-3 control-label">确认密码：</label>
               <div class="col-sm-8">
                   <input id="confirm_password"  class="form-control" type="password" value="${user.loginPwd}">
               </div>
     </div>
     <div class="form-group">
               <label class="col-sm-3 control-label">邮箱：</label>
               <div class="col-sm-8">
                   <input id="email" name="email" class="form-control" type="text" value="${user.email}">
               </div>
     </div>
     <div class="form-group">
               <label class="col-sm-3 control-label">手机号码：</label>
               <div class="col-sm-8">
                   <input id="mp" name="mp" class="form-control" type="text" value="${user.mp}">
               </div>
     </div>
     <div class="form-group">
               <label class="col-sm-3 control-label">联系电话：</label>
               <div class="col-sm-8">
                   <input id="telephone" name="telephone" class="form-control" type="text" value="${user.telephone}">
               </div>
     </div>
</div>

<div class="col-sm-6">
	<div class="form-group ">
     <label class="col-sm-3 control-label">公司：</label>
     <div class="col-sm-8">
        <select class="form-control m-b" name="companyId" id="companyId">
           </select>
     </div>
 </div>
 <div class="form-group ">
     <label class="col-sm-3 control-label">组织机构：</label>
     <div class="col-sm-8">
      <select class="form-control m-b" name="orgId" id="orgId">
                <option value="1">选项 1</option>
                <option value="2">选项 2</option>
                <option value="3">选项 3</option>
                <option value="4">选项 4</option>
         </select>
          </div>
 </div>
 <div class="form-group ">
     <label class="col-sm-3 control-label">用户类型：</label>
     <div class="col-sm-8">
      <select class="form-control m-b" name="userType" id="userType">
                <option value="1">选项 1</option>
                <option value="2">选项 2</option>
                <option value="3">选项 3</option>
                <option value="4">选项 4</option>
         </select>
          </div>
 </div>
 <div class="form-group ">
     <label class="col-sm-3 control-label">员工账户：</label>
     <div class="col-sm-8">
      <select class="form-control m-b" name="employeeFlag" id="employeeFlag">
                 <option value="1">选项 1</option>
                <option value="2">选项 2</option>
                <option value="3">选项 3</option>
                <option value="4">选项 4</option>
         </select>
          </div>
 </div>
 <div class="form-group ">
     <label class="col-sm-3 control-label">状态：</label>
     <div class="col-sm-8">
      <select class="form-control m-b" name="status" id="status">
                 <option value="1">选项 1</option>
                <option value="2">选项 2</option>
                <option value="3">选项 3</option>
                <option value="4">选项 4</option>
         </select>
          </div>
 </div>
               
</div>
</form>

<script>
$(function(){
	$.validator.setDefaults({
        highlight: function (element) {
            $(element).closest('.form-group').removeClass('has-success').addClass('has-error');
        },
        success: function (element) {
            element.closest('.form-group').removeClass('has-error').addClass('has-success');
        },
        errorElement: "span",
        errorClass: "help-block m-b-none",
        validClass: "help-block m-b-none"
    });
	
	// validate signup form on keyup and submit
    var validator = $("#editForm").validate({
        rules: {
            loginName: "required",
            showName: {
                required: true,
                minlength: 2
            },
            loginPwd: {
                required: true,
                minlength: 6
            },
            confirm_password: {
                required: true,
                minlength: 5,
                equalTo: "#loginPwd"
            },
            email: {
                required: true,
                email: true
            },
            topic: {
                required: "#newsletter:checked",
                minlength: 2
            },
            agree: "required"
        },
        messages: {
            loginName: "请输入登录名",
            showName: {
                required: "请输入您的显示名称",
                minlength: "显示名称必须两个字符以上"
            },
            loginPwd: {
                required: "请输入您的密码",
                minlength: "密码必须5个字符以上"
            },
            confirm_password: {
                required: "请再次输入密码",
                minlength: "密码必须5个字符以上",
                equalTo: "两次输入的密码不一致"
            },
            email: "请输入您的E-mail",
            agree: "必须同意协议后才能注册"
        }
    });
    
	
	//公司列表
	Utils.setOptions('${ctxPath}/system/company/combox','','id','cnName',"#companyId",${user.companyId});
	
	//点击保存按钮
	$(".save").click(function(){
		
		 if(validator.form()){ //若验证通过，则调用保存/修改方法
			 $.ajax({
				 url : '${ctxPath}/system/user/edit',
			        data : $("#editForm").serialize(),
			        success  : function(data) {
			        	//if(data.state == 200){
			        		$('#editUserModal').modal('hide');
			        		location.href="${ctxPath}/system/user";
			        		layer.alert("修改成功");
			        	//}else{
			        	//	layer.alert("修改失败");
			        	//}
					}
			    });
	      }
		 
	});
})
</script>